<template>
	<view class="sales_records">
		<u-calendar v-model="show" mode="range" btn-type='success' range-color='#26C281' range-bg-color='rgba(38, 194, 129, 0.13)' active-bg-color='#26C281' :safe-area-inset-bottom='true' @change="change"></u-calendar>
		<view class="team_top">
			<view class="nav">
				<view class="left" @click="show=true">
					<text class="time" :class="startTime?'time_active':''">{{startTime?startTime:'开始时间'}}</text>
					<text class="line">-</text>
					<text class="time" :class="endTime?'time_active':''">{{endTime?endTime:'结束时间'}}</text>
				</view>
				<view class="right" @click="queryBtn">查询</view>
			</view>
			<view class="num_list">
				<view class="txt">
					<text class="t_num">{{orderInfo.total_money || '--'}}</text>
					<text class="t_tip">总订单金额</text>
				</view>
				<view class="txt">
					<text class="t_num">{{orderInfo.make_money || '--'}}</text>
					<text class="t_tip">总利润</text>
				</view>
				<view class="txt">
					<text class="t_num">{{orderInfo.integral || '--'}}</text>
					<text class="t_tip">总消耗积分</text>
				</view>
			</view>
		</view>
		<view style="height: 232rpx;"></view>
		<!--  -->
		<view class="no_html" v-if="list.length==0">
			<image src="@/static/images/no_img5.png" mode=""></image>
			<text>暂无交易记录</text>
		</view>
		<!--  -->
		<view v-else>	
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="text">
					<text class="left" style="color: #333;">{{item.confirm_time_text}}</text>
					<text class="right" style="color: #26C281;">+{{item.make_money}}</text>
				</view>
				<view class="text">
					<text class="left">订单额</text>
					<text class="right">{{item.pay_money}}</text>
				</view>
				<view class="text">
					<text class="left">积分</text>
					<text class="right">-{{item.integral_text}}</text>
				</view>
			</view>
			<view class="mall_loading" v-if="list.length" style="padding-top: 24rpx;">
				<u-loadmore :status="status" color='#999' />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
				startTime:'',
				endTime:'',
				orderInfo:{
					integral:'',
					make_money:'',
					total_money:'',
				},
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				page: 1,
				list: [],
			};
		},
		onLoad() {},
		onShow() {
			this.page=1
			this.getList()
		},
		methods:{
			// 列表
			getList() {
				var that = this
				if(that.page==1){
					that.$tips.showLoading('加载中')
				}else{
					that.status = 'loading'
				}
				var params = {
					page:that.page,
					sta_time: that.startTime,
					end_time: that.endTime,
				}
				that.$httpApi.sellLog(params).then((res) => {
					if (res.code == 1) {
						that.orderInfo=res.data.orderInfo
						if (that.page == 1) {
							that.list = []
							that.$tips.hideLoading()
						}
						if (res.data.data.current_page == res.data.data.last_page) {
							that.status = 'nomore'
						} else {
							that.status = 'loadmore'
						}
						that.list = that.list.concat(res.data.data.data)
					}
				})
			},
			// 查询
			queryBtn(){
				this.page=1
				this.getList()
			},
			// 选择日期
			change(e) {
				this.startTime=e.startDate
				this.endTime=e.endDate
			},
		},
		onReachBottom() {
			if (this.status == 'nomore' || this.status == 'loading') {
				return
			}
			this.page++
			this.getList()
		},
	}
</script>

<style lang="less">
	.sales_records{
		width: 100%;
		.team_top{
			position: fixed;
			z-index: 10;
			width: 100%;
			background: #fff;
			border-bottom: 2rpx solid #f7f8fa;
			.nav{
				width: 100%;
				height: 100rpx;
				padding: 20rpx 32rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.left{
					width: 538rpx;
					height: 64rpx;
					padding: 0 30rpx;
					background: #F5F5F5;
					border-radius: 32rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;
					.line{
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #BEBEBE;
					}
					.time{
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #BEBEBE;
					}
					.time_active{
						color: #333;
					}
				}
				.right{
					width: 132rpx;
					height: 64rpx;
					line-height: 64rpx;
					text-align: center;
					font-size: 28rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					background: #26C281;
					border-radius: 32rpx;
				}
			}
			.num_list{
				width: 100%;
				padding: 24rpx 0;
				background: #fff;
				display: flex;
				justify-content: space-between;
				.txt{
					flex: 1;
					// width: 100%;
					border-left: 2rpx solid #f7f8fa;
					text{
						display: block;
						width: 100%;
						text-align: center;
					}
					.t_num{
						font-size: 32rpx;
						font-family: OPPOSans-Bold, OPPOSans;
						font-weight: bold;
						color: #222222;
					}
					.t_tip{
						padding-top: 8rpx;
						font-size: 24rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
					}
				}
				.txt:first-child{
					border-left: none;
				}
			}
		}
		.list{
			width: 100%;
			margin-top: 24rpx;
			padding: 8rpx 32rpx 32rpx;
			background: #fff;
			.text{
				width: 100%;
				padding-top: 24rpx;
				display: flex;
				justify-content: space-between;
				.left{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
				.right{
					font-size: 28rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #222222;
				}
			}
		}
	}
</style>
